package com.practice.exploreandroid;

import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.TabHost;
import android.widget.TextView;

public class UserPageActivity extends TabActivity {
	private TabHost tabHost;
	private Intent intent;
	
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);
        // Set view.
        setContentView(R.layout.userpage);

        setTabs();
    }
    
    public void setTabs()
    {
		tabHost = getTabHost();
		
		// Create intents then call addTab to create tabs in tabHost.
		intent = new Intent(this, GamesActivity.class);
    	addTab(R.string.games_name, R.drawable.ic_tab_games);
    	
		intent = new Intent(this, CashierActivity.class);
    	addTab(R.string.cashier_name, R.drawable.ic_tab_cashier);
    	
		intent = new Intent(this, SettingsActivity.class);
    	addTab(R.string.settings_name, R.drawable.ic_tab_settings);
    }
    
	private void addTab(int labelId, int drawableId) 
	{
		// Create new tab.
		TabHost.TabSpec spec = tabHost.newTabSpec("tab" + labelId);		
		
		View tabIndicator = LayoutInflater.from(this).inflate(R.layout.tab_indicator, getTabWidget(), false);
		
		// Set tab properties.
		TextView title = (TextView) tabIndicator.findViewById(R.id.title);
		title.setText(labelId);
		ImageView icon = (ImageView) tabIndicator.findViewById(R.id.icon);
		icon.setImageResource(drawableId);
		
		// Add tabs to tabHost.
		spec.setIndicator(tabIndicator);
		spec.setContent(intent);
		tabHost.addTab(spec);
	
		//tabHost.getTabWidget().setStripEnabled(true);
		
	}
}